package cn.stylefeng.guns.modular.rest;


import cn.stylefeng.guns.modular.comm.entity.MoneyHistory;
import cn.stylefeng.guns.modular.comm.entity.WxMiniUser;
import cn.stylefeng.guns.modular.comm.model.params.MoneyHistoryParam;
import cn.stylefeng.guns.modular.comm.model.params.WxMiniUserParam;
import cn.stylefeng.guns.modular.comm.service.MoneyHistoryService;
import cn.stylefeng.guns.modular.comm.service.WxMiniUserService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.SuccessResponseData;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 绑定控制器
 *
 * @author
 * @Date 2019-11-18 13:24:11
 */
@RestController
@RequestMapping("/gunsApi/money/history")
public class ApiNeedTokenMoneyHistoryController extends BaseController {
    @Autowired
    private WxMiniUserService wxMiniUserService;
    @Autowired
    private MoneyHistoryService moneyHistoryService;

    /**
     * 绑定
     */
    @GetMapping(value = "list")
    public Object list(MoneyHistoryParam moneyHistoryParam) {
        Map map = new HashMap();
        SuccessResponseData SUCCESS_TIP = new SuccessResponseData();
        QueryWrapper queryWrapper = new QueryWrapper<MoneyHistory>();
        queryWrapper.orderByDesc("create_time");
        queryWrapper.eq("open_id", moneyHistoryParam.getOpenId());
        if (ToolUtil.isNotEmpty(moneyHistoryParam.getType())) {
            queryWrapper.eq("type", moneyHistoryParam.getType());
        }
        List<MoneyHistory> moneyHistories = moneyHistoryService.list(queryWrapper);
        map.put("moneyHistories", moneyHistories);

        SUCCESS_TIP.setData(map);
        return SUCCESS_TIP;
    }

}


